<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改校区')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-campus-edit" th:object="${sysCampus}">
            <input id="id" name="id" th:field="*{id}" type="hidden">
            <input id="tenantId" th:field="*{tenantId}" type="hidden">
            <input id="province2" name="province2" th:value="*{province}" type="hidden">
            <input id="city2" name="city2" th:value="*{city}" type="hidden">
            <input id="area2" name="area2" th:value="*{area}" type="hidden">

            <!--<div class="form-group" th:if="${@permission.hasPermi('system:superAdmin:opt')} != 'hidden'">
                <label class="col-sm-3 control-label">请选择租户：</label>
                <div class="col-sm-8">
                    <select name="tenantId2" id="tenantId2"  class="form-control" disabled>
                        <option th:each="t : ${tenantList}" th:selected="${t.tenantId eq sysCampus.tenantId}"  th:text="${t.tenantName}" th:value="${t.tenantId}"></option>
                    </select>
                </div>
            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required" >校区名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" required maxlength="30">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">联系电话：</label>
                <div class="col-sm-8">
                    <input  id="phone" th:field="*{phone}"  name="phone" class="form-control" type="text" required maxlength="30"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">校区地址：</label>
                <div class="col-sm-8" id="distpicker1">
                    <div class="col-sm-4">
                        <select class="form-control" name="province" th:field="*{province}"></select>
                    </div>
                    <div class="col-sm-4">
                        <select class="form-control" name="city" th:field="*{city}"></select>
                    </div>
                    <div class="col-sm-4">
                        <select class="form-control" name="area" th:field="*{area}" > </select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">&nbsp;</label>
                <div class="col-sm-8">
                    <input id="address" th:field="*{address}" name="address" class="form-control" type="text" placeholder="请输入详细地址" required/>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">负责人：</label>
                <div class="col-sm-8">
                    <input id="major" th:field="*{major}" name="major" class="form-control" type="text" required/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">校区介绍：</label>
                <div class="col-sm-8">
                    <textarea id="introduce" th:field="*{introduce}" name="introduce" class="form-control" maxlength="300"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: distpicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "system/campus"
        $("#form-campus-edit").validate({
            onkeyup: false,
            rules:{
                name:{
                    remote: {
                        url: ctx + "system/campus/checkNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "name" : function() {
                                return $.common.trim($("#name").val());
                            },
                            "tenantId" : function() {
                                return $.common.trim($("#tenantId").val());
                            },
                            "id" : function() {
                                return $.common.trim($("#id").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
                orderNum:{
                    digits:true
                },
            },
            messages: {
                "name": {
                    remote: "名称已存在！"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-campus-edit').serialize());
            }
        }
        $(function(){
            $("#distpicker1").distpicker({
                province: $("#province2").val(),
                city: $("#city2").val(),
                district: $("#area2").val()
            });
        })

    </script>
</body>
</html>